import {fileURLToPath, URL} from 'node:url'

import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vitejs.dev/config/
export default defineConfig({
    css: {
        preprocessorOptions: {
            scss: {
                api: "modern-compiler"//使用现代版编译器api 处理scss文件
            }
        }
    },
    plugins: [
        vue({
            template: {
                compilerOptions: {
                    isCustomElement: tag => ["swiper-slide", "swiper-container"].includes(tag)
                }
            }
        }),
        vueJsx(),
    ],
    resolve: {

        extensions: ['.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url)),
            '@assets': fileURLToPath(new URL('./src/assets', import.meta.url)),
            '@components': fileURLToPath(new URL('./src/components', import.meta.url)),
            '@router': fileURLToPath(new URL('./src/router', import.meta.url)),
            '@stores': fileURLToPath(new URL('./src/stores', import.meta.url)),
            '@views': fileURLToPath(new URL('./src/views', import.meta.url)),
            '@utils': fileURLToPath(new URL('./src/utils', import.meta.url)),
            '@mixin': fileURLToPath(new URL('./src/mixin', import.meta.url))
        }
    },
    server: {
        proxy: {
            "/web_console_api": {
                target: "https://zl.yugu.net.cn",
                changeOrigin: true
            }
        }
    }
})
